package com.github.m6d21.sso.business.controller.test;

import com.github.m6d21.sso.core.annotation.Login;
import com.github.m6d21.sso.support.model.Response;
import com.github.m6d21.sso.support.session.SsoSessionHolder;
import com.github.m6d21.sso.support.util.ResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Map;
import javax.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 *<p>
 *
 *</p>
 *
 * @author liuyang
 * @date 2018-12-07 Fri 13:27:18
 * @since 1.0.0
 */
@Api(value = "test-sso", description = "sso测试")
@Validated
@RestController
@RequestMapping("/test/sso")
public class SsoController {

    @ApiOperation(value = "@NotNull测试", httpMethod = "GET")
    @GetMapping("/session")
    @ResponseBody
    @Login(cookieExpire = 3600)
    public Response ssoSession
        (@NotNull(message = "用户名不能为空") @RequestParam("username") String username,
            @NotNull(message = "密码不能是空") @RequestParam("password") String password) {
        Map<String,String> sessionAttributes= SsoSessionHolder.getAllAttributes();
        return ResponseUtil.success(sessionAttributes);
    }
}
